package com.mj.mes.system.SysResource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by mj on 2017/3/30.
 */
@Service
@ConfigurationProperties(value = "sysResourceService")
@Transactional
public class SysResourceService {
    @Autowired
    private SysResourceDao sysResourceDao;

    public List<SysResource> findAll() {
        return sysResourceDao.findAll();
    }
    public SysResource findByResourceName(String resourceName){
        return sysResourceDao.findByResourceName(resourceName);
    }
    public List<SysResource> findBySysResource(SysResource sysResource){
        return  sysResourceDao.findBySysResource(sysResource);
    }
    public SysResource findOne(Long id){
        return sysResourceDao.findOne(id);
    }
    public Set<SysResource> findInBacth(List<Long>ids){
        List<SysResource> list=sysResourceDao.findAll(ids);
        return new HashSet<SysResource>(list);
    }
    public void save(SysResource sysResource){
        sysResourceDao.save(sysResource);
    }

    /**
     * 根据ID删除，，仅使用于单个无外键的表
     * @param id
     */
    public void delete(Long id){
        sysResourceDao.delete(id);
    }

    /**
     * 级联删除
     * @param sysResource
     */
    public void remove(SysResource sysResource){
        sysResourceDao.delete(sysResource);
    }
}
